package hu.kisprof.quiz.view.panels;

import java.awt.GridLayout;

import hu.kisprof.quiz.model.bean.Player;
import hu.kisprof.quiz.view.Labels;
import hu.kisprof.quiz.view.QuizGUI;

import javax.swing.JLabel;
import javax.swing.JPanel;

public class PlayerPanel extends JPanel {
	private JLabel name;
	private JLabel score;
	private String plyName;
	private QuizGUI gui;

	/**
	 * 
	 */
	private static final long serialVersionUID = -618470076316603512L;
	
	
	
	public PlayerPanel(QuizGUI gui, Player ply){
		super(new GridLayout(1,2));
		this.gui=gui;
		plyName=ply.getUsername();
		name = new JLabel(plyName);
		score = new JLabel ();
		refreshPoint();
		this.add(new JLabel(Labels.username+":"));
		this.add(name);
		this.add(new JLabel(Labels.score+":"));
		this.add(score);
	}
	
	public void refreshPoint(int i){
		score.setText(String.valueOf(i));
		this.validate();
	}
	
	public void refreshPoint(){
		refreshPoint(gui.getControl().getPoints(plyName));
	}

	
}
